//
//  HFCalendarBottomView.m
//  HFCalendar
//
//  Created by Luffy on 2021/8/25.
//

#import "HFCalendarBottomView.h"
#import "HFCalendarHeader.h"

@implementation HFCalendarBottomView {
    UIButton *_sureBtn;
    UILabel *_contentLabel;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    self.backgroundColor = UIColor.whiteColor;
    
    UIView *baseView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height - 10)];
    baseView.backgroundColor = UIColor.whiteColor;
    [self addSubview:baseView];
    
    _sureBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _sureBtn.frame = CGRectMake(self.frame.size.width - 85, (baseView.frame.size.height - 40) / 2, 70, 40);
    _sureBtn.backgroundColor = HFHexColor(0x1678FF);
    [_sureBtn setTitle:@"确定" forState:UIControlStateNormal];
    [_sureBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    [_sureBtn setTitleColor:HFHexColorA(0xFFFFFF, 0.5) forState:UIControlStateDisabled];
    _sureBtn.titleLabel.font = [UIFont systemFontOfSize:15.f];
    _sureBtn.layer.cornerRadius = 5;
    [_sureBtn addTarget:self action:@selector(sureBtnDidClick) forControlEvents:UIControlEventTouchUpInside];
    [baseView addSubview:_sureBtn];
    
    _contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, (baseView.frame.size.height - 40) / 2, self.frame.size.width - 110, 40)];
    _contentLabel.textColor = HFHexColor(0x666666);
    _contentLabel.font = [UIFont systemFontOfSize:13.f];
    _contentLabel.textAlignment = NSTextAlignmentLeft;
    [baseView addSubview:_contentLabel];
}

- (void)setContentStr:(NSString *)contentStr {
    _contentStr = contentStr;
    
    _contentLabel.text = contentStr;
    _sureBtn.enabled = contentStr.length > 0 ? YES : NO;
}

- (void)sureBtnDidClick {
    if (self.sure_callBack) {
        self.sure_callBack(self.contentStr);
    }
}

@end
